﻿using System;
using Growl.Connector;

namespace Yks.Notify.Client.Services.Impl
{
    internal class GrowlNotifyShower : INotifyShower
    {
        public const string AppName = "Yks.Notify.Client";
        public const string NotifyType = "TFS";

        private readonly Lazy<GrowlConnector> _growlConnectorLazy = new Lazy<GrowlConnector>(() =>
        {
            var conn = new GrowlConnector();
            var appname = "Yks.Notify.Client";
            var thisApp = new Growl.Connector.Application(appname);
            var simpleGrowlType = new NotificationType(NotifyType);
            conn.Register(thisApp, new NotificationType[] {simpleGrowlType});
            return conn;
        });

        void INotifyShower.ShowNotify(string id, string title, string message)
        {
            _growlConnectorLazy.Value.Notify(new Notification(AppName, NotifyType, id, title, message));
        }
    }
}